<template>
	<!-- 我的代金券 -->
	<view class="">
		<view class="header">
			<view @click="currentChange(1)" class="header-item" :class="current==1?'header-item-active':''">
				已使用
			</view>
			<view @click="currentChange(0)" class="header-item" :class="current==0?'header-item-active':''">
				未使用
			</view>
		</view>
		<view class="list" v-if="list.length>0">
			<view class="list-item" v-for="(item,index) in list" :key="index">
				<view class="list-item-left">
					<view class="lil-name">{{item.merchant.shop_name||'未知'}}</view>
					<view class="lil-good">{{item.goods.name}}</view>
					<view class="lil-time">{{item.created_at}}</view>
				</view>
				<view class="list-item-right">
					<view class="lir-price" v-if="true">
						{{item.amount}}<text>元</text>
					</view>
					<view class="lir-old" v-else>
						已使用
					</view>
				</view>
			</view>
		</view>
		<view class="isNull" v-if="list.length==0">
			<image src="@/static/nodata.png" mode=""></image>
			<text>暂时没有数据~</text>
		</view>
	</view>
</template>

<script>
	import {getBVoucherListApi} from "@/common/api.js"
	export default {
		data() {
			return {
				current: 1,
				list: []
			}
		},
		onLoad() {
			this.getBVoucherList()
		},
		methods:{
			// 获取现金券列表
			getBVoucherList(){
				getBVoucherListApi({is_use:this.current}).then(res=>{
					this.list = res.data
				})
			},
			currentChange(e){
				this.current = e
				this.getBVoucherList()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.header {
		width: 100%;
		background: #fff;
		display: flex;
		align-items: center;
		border: 1rpx solid #3c9cff;
		box-sizing: border-box;
	}

	.header-item {
		flex: 1;
		text-align: center;
		padding: 14rpx 0;
		font-size: 32rpx;
	}

	.header-item-active {
		background: #3c9cff;
		color: #fff;
	}
	
	.list{
		padding: 0 30rpx;
		
	}
	
	.list-item{
		padding: 30rpx;
		background: #fff;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-radius: 10rpx;
		margin-top: 20rpx;
	}
	
	.lir-price{
		font-size: 40rpx;
		color: red;
		text{
			font-size: 28rpx;
		}
	}
	
	.lir-old{
		font-size: 32rpx;
		color: #999;
	}
	
	.lil-name{
		font-size: 32rpx;
	}
	
	.lil-good{
		font-size: 28rpx;
		margin: 10rpx 0;
	}
	
	.lil-time{
		font-size: 24rpx;
		color: #999;
	}
	
	.isNull{
		margin-top: 200rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		image{
			width: 410rpx;
			height: 240rpx;
			flex-shrink: 0;
		}
		text{
			margin-top: 30rpx;
			font-size: 28rpx;
			color: #999;
		}
	}
</style>
